library(UpSetR)

A <- sample(1:1000, 400, replace = FALSE);
B <- sample(1:1000, 600, replace = FALSE);
C <- sample(1:1000, 350, replace = FALSE);
D <- sample(1:1000, 550, replace = FALSE);
E <- sample(1:1000, 375, replace = FALSE);
G <- sample(1:1000, 200, replace = FALSE);
H <- sample(1:1000, 777, replace = FALSE);

dataForUpSetPlot <- list(A = A, B = B, C = C, D = D, E = E, G = G, H = H)
setsBarColors <- c('#EA4335', '#FBBC05', '#34A853', '#4285F4')
### sort by degree
dd <- upset(fromList(dataForUpSetPlot),
            nsets = length(dataForUpSetPlot),
            nintersects = 1000,
            sets = c("A", "B", "C", "D"),
            #keep.order = TRUE,
            point.size = 3,
            line.size = 1,
            number.angles = 0,
            text.scale = c(1.5, 1.2, 1.2, 1, 1.5, 1), # ytitle, ylabel, xtitle, xlabel, sets, number
            order.by = "degree",
            matrix.color = "black",
            main.bar.color = 'black',
            mainbar.y.label = 'Intersection Size',
            sets.bar.color = setsBarColors,
            queries = list(list(query = intersects,
                                params = list('A', 'B', 'C'), color = "orange", active = T)))

path.package("ggplot2")